﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="AppList.aspx.cs" Inherits="BuXiaChu.OrderDishes.Web.Admin.Sys.AppList" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ Register TagPrefix="Menu" TagName="Header" Src="~/Modules/Menu/Header.ascx" %>
<%@ Register TagPrefix="Menu" TagName="Footer" Src="~/Modules/Menu/Footer.ascx" %>
<%@ Register TagPrefix="Menu" TagName="SystemLeft" Src="~/Modules/Menu/SystemLeft.ascx" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
    <link media="screen, projection" rel="stylesheet" type="text/css" href="/css/Blueprint/screen.css" />
    <link media="screen, projection" rel="stylesheet" type="text/css" href="/css/main.css" />

    <script type="text/javascript" src="../js/Extend.js"></script>

    <script type="text/javascript" src="../js/Common.js"></script>

    <script type="text/javascript" src="../js/jquery-vsdoc.js"></script>

</head>
<body>
    <div class="container">
        <Menu:Header ID="Header1" runat="server" />
        <form id="form1" runat="server">
        <Menu:SystemLeft ID="menu_SystemLeft" runat="server" />
        <div class="span-20 last">
            <div class="boxc">
                <input type="hidden" id="txt_Id" />
                <span>网站名字：</span>
                <input type="text" id="txt_Name" />
                <br />
                <span>网站地址：</span>
                <input type="text" id="txt_Website" />
                <br />
                <span>网站描述：</span>
                <textarea style="width: 200px; height: 50px" id="txt_Desc"></textarea>
                <br />
                <input type="button" id="btn_Save" value="新增" />
                <input type="button" id="btn_Cancle" value="取消" />
            </div>
            <div class="boxc">
                <table>
                    <tr>
                        <td>
                            编码
                        </td>
                        <td>
                            名称
                        </td>
                        <td>
                            网站地址
                        </td>
                        <td>
                            描述
                        </td>
                        <td>
                            操作
                        </td>
                    </tr>
                    <% foreach (var item in appList)
                       {%>
                    <tr>
                        <td>
                            <%= item.ApplicationId %>
                        </td>
                        <td>
                            <%=HttpUtility.HtmlEncode(item.Name)%>
                        </td>
                        <td>
                            <%=HttpUtility.HtmlEncode(item.Website)%>
                        </td>
                        <td>
                            <%=HttpUtility.HtmlEncode(item.Description)%>
                        </td>
                        <td>
                            <a href="javascript:;" onclick="modifyData(this)">修改</a>
                        </td>
                    </tr>
                    <%} %>
                </table>
            </div>
        </div>
        </form>
        <Menu:Footer ID="Footer1" runat="server" />
    </div>
</body>

<script type="text/javascript">
    $("#btn_Save").click(function() {
        var name = jDoc("txt_Name").value.trim();
        var desc = jDoc("txt_Desc").value.trim();
        var website = jDoc("txt_Website").value.trim();
        var id = jDoc("txt_Id").value.trim();
        if (name == "") {
            alert("网站名字");
            jDoc("#txt_Name").focus();
        } else {
            var obj = { name: name, desc: desc, website: website, t: 2 };
            if (jDoc("btn_Save").value.trim() != "新增") {
                obj.t = 3;
                obj.id = id;
            }
            $.post("Apps.ashx", obj, function(data) {
                if (data.success) {
                    alert("操作成功");
                    jDoc.reload();
                }
            }, "json")
        }
    });
    $(jDoc("btn_Cancle")).click(function() {
        jDoc("txt_Id").value = "";
        jDoc("txt_Name").value = "";
        jDoc("txt_Desc").value = "";
        jDoc("txt_Website").value = "";
        jDoc("btn_Save").value = "新增";
    });

    function modifyData(o) {
        var tr = o.parentNode.parentNode;
        jDoc("txt_Id").value = tr.cells[0].innerHTML.trim();
        jDoc("txt_Name").value = tr.cells[1].innerHTML.trim();
        jDoc("txt_Desc").value = tr.cells[2].innerHTML.trim();
        jDoc("txt_Website").value = tr.cells[3].innerHTML.trim();

        jDoc("txt_Name").focus();
        jDoc("btn_Save").value = "保存";
    }
</script>
